import {
  createRouter,
  createWebHashHistory,
  RouteLocationNormalized
} from 'vue-router'
import routes from './routes'

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach(
  (to: RouteLocationNormalized, from: RouteLocationNormalized, next) => {
    document.title = (to.meta.title as string) || '默认标题' // 若路由中没有meta.title，则使用默认标题
    next()
  }
)

export default router
